define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {


            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'wallet/withdrawal/index',
                    edit_url: 'wallet/withdrawal/edit',
                    table: 'withdrawal',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        //{field: 'uid', title: __('Uid')},
                        {field: 'user.username', title: __('Username')},

                        {field: 'type', title: __('Type'),formatter: Table.api.formatter.status, searchList: {"USDT": __('USDT'),"FC": __('FC')}},

                        {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'addr', title: __('Addr')},
                        {field: 'service_charge', title: __('Service_charge'), operate:'BETWEEN'},
                        {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {"-1": __('已拒绝'),0: __('审批'), 1: __('已同意')}},
                        {field: 'real_amount', title: __('Real_amount'), operate:'BETWEEN'},
                        // {field: 'usdt', title: __('Exchange USDT'), operate:'BETWEEN'},
                        // {field: 'btc', title: __('Btc'), operate:'BETWEEN'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'approval_time', title: __('Approval_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                        {field: 'operate', title: __('Operate'), table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});